<script>
import InfoList from '@/views/mall/myOrder/infoList'
import { getRefundList } from '@/api/myOrder/myOrder'

export default {
  name: 'RefundOrder',
  components: { InfoList },
  data() {
    return {
      activeName: '1',
      // 表格数据
      tableData: [],
      // 加载状态
      loading: false,
      // 订单编号
      orderCode: '',
      // 工厂
      factory: '',
      // 服务中心
      serviceCenter: '',
      pageNum: 1,
      pageSize: 10,
      total: 0
    }
  },
  created() {
    this.getTableData()
  },
  methods: {
    handleList(tab) {
      this.activeName = tab.name
      this.getTableData()
    },
    // 获取表格数据
    getTableData() {
      this.loading = true
      const params = {
        pageNo: this.pageNum,
        pageSize: this.pageSize,
        status: parseInt(this.activeName),
        orderCode: this.orderCode
      }
      getRefundList(params)
        .then((res) => {
          if (res.code === '00000') {
            this.tableData = res.data.rows
            this.total = res.data.totalRows
          }
          this.loading = false
        })
        .catch((error) => {
          this.loading = false
        })
    },
    // 分页
    handleCurrentChange(val) {
      this.pageNum = val
      this.getTableData()
    },
    // 搜索
    handleSearch() {
      this.getTableData()
    },
    reLoad() {
      this.getTableData()
    },
    changeSize(val) {
      this.pageSize = val
      this.getTableData()
    }
  }
}
</script>

<template>
  <div class="InfoPage">
    <el-tabs v-model="activeName" type="border-card" @tab-click="handleList">
      <div class="top">
        <el-input
          v-model="orderCode"
          placeholder="请填写订单编号"
          style="width: 200px"
          clearable
        ></el-input>
        <el-button
          :style="{ marginLeft: '20px' }"
          circle
          icon="el-icon-search"
          @click="handleSearch"
        ></el-button>
        <el-button :style="{ marginLeft: '20px' }" round size="mini"
        >导出
        </el-button>
      </div>
      <el-tab-pane label="待处理" name="1">
        <InfoList
          :activeName="activeName"
          :tableData="tableData"
          :loading="loading"
          @reLoad="reLoad"
          @handleSearch="handleSearch"
        ></InfoList>
      </el-tab-pane>
      <el-tab-pane label="已处理" name="2">
        <InfoList
          :activeName="activeName"
          :tableData="tableData"
          :loading="loading"
          @reLoad="reLoad"
          @handleSearch="handleSearch"
        ></InfoList>
      </el-tab-pane>
      <el-tab-pane label="已驳回" name="4">
        <InfoList
          :activeName="activeName"
          :tableData="tableData"
          :loading="loading"
          @handleSearch="handleSearch"
        ></InfoList>
      </el-tab-pane>
      <el-tab-pane label="已打款" name="3">
        <InfoList
          :activeName="activeName"
          :tableData="tableData"
          :loading="loading"
          @handleSearch="handleSearch"
        ></InfoList>
      </el-tab-pane>
    </el-tabs>
    <el-row
      type="flex"
      justify="end"
      style="margin-top: 20px; margin-right: 20px; margin-bottom: 20px"
    >
      <el-pagination
        background
        @current-change="handleCurrentChange"
        @size-change="changeSize"
        :current-page="pageNum"
        :page-size="pageSize"
        :page-sizes="[10, 20, 30, 40]"
        layout="total, prev, pager, next, jumper, sizes"
        :total="total"
      >
      </el-pagination>
    </el-row>
  </div>
</template>

<style scoped lang="scss">
.InfoPage {
  height: 1041px;
  background: #fff;
}
</style>
